import 'package:boss/color_constant.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class SplashPaginationPlugin extends SwiperPlugin {
  @override
  Widget build(BuildContext context, SwiperPluginConfig config) {
    List<Widget> children = [];

    for (var index = 0; index < config.itemCount; index++) {
      children.add(_CustomPagination(index == config.activeIndex));
    }
    return Align(
      alignment: Alignment.bottomCenter,
      child: Container(
        margin: EdgeInsets.only(
          bottom: 80.w,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: children,
        ),
      ),
    );
  }
}

class _CustomPagination extends StatelessWidget {
  final bool isActive;

  const _CustomPagination(this.isActive);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 12.w,
      width: ScreenUtil.instance.setHeight(isActive ? 38 : 12),
      margin: EdgeInsets.symmetric(
        horizontal: 10.w,
      ),
      decoration: BoxDecoration(
        color: !isActive ? ColorConstant.ffcc : ColorConstant.ff5770f6,
        borderRadius: BorderRadius.circular(
          12.w,
        ),
      ),
    );
  }
}
